package com.example.multilpeDataSource.controller;

import com.example.multilpeDataSource.entity.User;
import com.example.multilpeDataSource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangzhendong
 * @data 2020-02-08 14:19
 */
@RestController
@RequestMapping("/route")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/get")
    public User findById(){
        return userService.findById(1);
    }

    @PostMapping("/add")
    public String add(){
        return userService.add(1, "哈哈哈") > 0 ? "添加成功" : "添加失败";
    }

    @PostMapping("/add1")
    public String add1(){
        return userService.add1(1, "哈哈哈") > 0 ? "添加成功" : "添加失败";
    }

}
